package com.xbongbong.saas.domain.dao;

import com.xbongbong.saas.domain.entity.PublicGroupCustomerEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @description: 公海池客户
 * @Author: hongxiao
 * @date: 2019-03-05 22:19
 * @since v1.0
 */
@Repository
@Mapper
public interface PublicGroupCustomerDao {
    Integer insert(PublicGroupCustomerEntity publicGroupCustomer);
    Integer update(PublicGroupCustomerEntity publicGroupCustomer);

    Integer insertBatch(@Param("list") List<PublicGroupCustomerEntity> list);

    Integer deleteByKey(@Param("key") Long key, @Param("corpid") String corpid);
    PublicGroupCustomerEntity getByKey (@Param("key") Long key,@Param("corpid") String corpid);


    List<PublicGroupCustomerEntity> findEntitys(@Param("param")Map<String ,Object> param);
    Integer getEntitysCount(@Param("param")Map<String ,Object>  param);

    /**
     * 根据公海池分组id删除公海客户
     * @param publicGroupId 公海池分组id
     * @param corpid 公司id
     * @return
     * @throws
     *
     * @author hongxiao
     * @date: 2019-03-05 22:25
     * @since v1.0
     * @version v1.0
     */
    Integer deleteByPublicGroupId(@Param("publicGroupId") Long publicGroupId,@Param("corpid") String corpid);

    /**
     * 删除某些分组所有的（或与某客户的）关联关系
     * @param publicGroupIdIn 公海池分组id列表
     * @param corpid 公司id
     * @param customerId 客户id
     * @return
     * @throws
     *
     * @author hongxiao
     * @date: 2019-03-05 22:24
     * @since v1.0
     * @version v1.0
     */
    Integer deleteByPublicGroupIdList(@Param("publicGroupIdIn") List<Long> publicGroupIdIn,@Param("corpid") String corpid,@Param("customerId") Long customerId);

    /**
     * 根据客户id删除公海池客户
     * @param customerId 客户id
     * @param corpid 公司id
     * @return
     * @throws
     *
     * @author hongxiao
     * @date: 2019-03-05 22:24
     * @since v1.0
     * @version v1.0
     */
    Integer deleteByCustomerId(@Param("customerId") Long customerId,@Param("corpid") String corpid);

    /**
     * 删除某些客户所有的（或与某分组的）关联关系
     * @param customerIdIn 客户id列表
     * @param corpid 公司id
     * @param publicGroupId 公海池分组id
     * @return
     * @throws
     *
     * @author hongxiao
     * @date: 2019-03-05 22:22
     * @since v1.0
     * @version v1.0
     */
    Integer deleteByCustomerIdList(@Param("customerIdIn") List<Long> customerIdIn,@Param("corpid") String corpid,@Param("publicGroupId") Long publicGroupId);

    /**
     * 查找符合条件的客户id
     * @param param 入参
     * @return
     * @throws
     *
     * @author hongxiao
     * @date: 2019-03-05 22:21
     * @since v1.0
     * @version v1.0
     */
    List<Long> findCustomerIds(@Param("param")Map<String ,Object>  param);

    /**
     *
     * @param param 入参
     * @return
     * @throws
     *
     * @author hongxiao
     * @date: 2019-03-05 22:22
     * @since v1.0
     * @version v1.0
     */
    List<Map<String,Object>> getBindCountMap(@Param("param")Map<String ,Object>  param);
}
